package cav;

import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;

public class CavView extends BasicGame
{
	protected boolean[][] _map;
	protected Image _niv1;
	protected Image _wall;

	public CavView(String title) {
		super(title);
	}

	@Override
	public void render(GameContainer arg0, Graphics arg1) throws SlickException {

		
		for (int i = 0; i < _map[0].length; i++)
		{
			for (int j = 0; j < _map.length; j++)
			{
				if (_map[i][j] )
				{
					_wall.draw(i * _wall.getWidth(), j * _wall.getHeight());
				}
			}
		}

	}

	@Override
	public void init(GameContainer arg0) throws SlickException {
		calculate();
		_niv1 = new Image("data/astar.bmp");
		_wall = new Image("data/wall.bmp");

	}

	@Override
	public void update(GameContainer gc, int arg1) throws SlickException {
		Input input = gc.getInput();
		if (input.isKeyPressed(Input.KEY_A))
		{
			calculate();
		}
	}

	public void calculate() {
		_map = GenerateurCaverne.getCavern();
	}

}
